﻿@model SCMS.UI.Models.ViewExpsClaims
@{AjaxOptions ajaxOpts = new AjaxOptions
{
    UpdateTargetId = "popup-page",
    LoadingElementId = "popup-loading",
    HttpMethod = "Post",
    Url = Url.Action("ApproveECF"),
    OnBegin = "return VerifyBLBalance(" + Model.ExpenseClaimItems.Count + ")",
    OnSuccess = "ReviewComplete('" + Model.EntityExpseRqst.RefNumber + " approved successfully.', 'ECF Approval Complete')"
};}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Ajax.BeginForm(null, null, ajaxOpts, new { @class = "form" }))
{
    @Html.ValidationSummary(true)
    <h4 style="text-align: center;">EXPENSE CLAIM FORM</h4>
    <center><b>@Model.EntityExpseRqst.RefNumber</b></center>
    <br />
    <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
        <tr class="gridheader">
            <th align="center" width="33%">
                Date
            </th>
            <th align="center" width="33%">
                Currency of Expense
            </th>
            <th align="center" width="34%">
                Currency Converted to
            </th>
        </tr>
        <tr class="gridodd">
            <td align="center">
                @Model.EntityExpseRqst.RequestDate.ToString("dd/MM/yyyy")
                @Html.HiddenFor(e => e.EntityExpseRqst.Id)
            </td>
            <td align="center">
                @Model.ExpsCurrency.ShortName
                @Html.HiddenFor(e => e.EntityExpseRqst.ExpenseCurrencyId)
                <input type="hidden" id="expenseCurrency" value="@Model.ExpsCurrency.ShortName" />
                <input type="hidden" id="currencyId" value="@Model.ExpsCurrency.Id" />
            </td>
            <td align="center">
                @Html.DropDownListFor(e => e.ConversionCurrencyId, Model.Currencies, new { @id = "convCurrencyId", @onchange = "javascript:onChangeCurrency()" })
                @Html.ValidationMessageFor(e => e.ConversionCurrencyId)
            </td>
        </tr>
        <tr class="gridheader">
            <th align="center">
                Expense Claim by
            </th>
            <th align="center">
                Title
            </th>
            <th align="center">
                Exchg. Rate of Conversion
            </th>
        </tr>
        <tr class="gridodd">
            <td align="center">
                @Model.EntityExpseRqst.Staff1.Person.FirstName &nbsp; @Model.EntityExpseRqst.Staff1.Person.OtherNames
            </td>
            <td align="center">
                @Model.EntityExpseRqst.Staff1.Designation.Name
            </td>
            <td align="center">
                @Html.TextBoxFor(e => e.ConversionRate, new { @id = "conversionRate", @class = "numericTb", @onblur = "javascript:changeECFExRate()" })
                @Html.ValidationMessageFor(e => e.ConversionRate)
            </td>
        </tr>
    </table>
    <table width="98%" align="center" cellspacing="0" cellpadding="0">
        <tr>
            <td width="33%">&nbsp;</td>
            <td width="33%">&nbsp;</td>
            <td id="fxRateInfo" align="center" width="34%" style="font-size: smaller; font-style: italic; font-weight: bold;">
                
            </td>
        </tr>
    </table>
    <br />
    <p id="budgetCheckStatus"></p>
    <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
        <tr class="gridheader">
            <th rowspan="2">
                Description
            </th>
            <th colspan="3">
                Coding
            </th>
            <th>
                Transaction
            </th>
            <th>
                Currency Conversion
            </th>
        </tr>
        <tr class="gridheader">
            <th>
                Account Code
            </th>
            <th>
                Project No
            </th>
            <th>
                Budget Line
            </th>
            <th>
                Amount
            </th>
            <th>
                Converted Amount
            </th>
        </tr>
        @{
           int num = 0; string pbDiv = ""; string rowId = "";
           for (int i = 0; i < Model.ExpenseClaimItems.Count; i++)
           {
               num = i + 1;
               pbDiv = "PBlines" + num;
               rowId = "row" + i;
            <tr id="@rowId">
                <td style="text-align: left;">
                    @Model.ExpenseClaimItems[i].EntityExpseItem.ItemDescription
                    @Html.HiddenFor(e => Model.ExpenseClaimItems[i].EntityExpseItem.Id)
                </td>
                <td style="text-align: left;">
                    @Html.DropDownListFor(e => Model.ExpenseClaimItems[i].AccountCode, Model.ExpenseClaimItems[i].AccountCodes)
                </td>
                <td style="text-align: left;">
                    @Html.DropDownListFor(e => Model.ExpenseClaimItems[i].ProjectDonorId, Model.ExpenseClaimItems[i].ProjectDonors, new { @onchange = "onChangeProjectNoForECF(this," + num + ")" })
                </td>
                <td style="text-align: left;">
                    <div id="@pbDiv">
                        @Html.DropDownListFor(e => Model.ExpenseClaimItems[i].BudgetLineId, Model.ExpenseClaimItems[i].BudgetLines, new { onchange = "javascript:checkBalance4Review(this)" })
                        @Html.ValidationMessageFor(e => Model.ExpenseClaimItems[i].BudgetLineId)
                    </div>
                </td>
                <td style="text-align: right;">
                    @Html.TextBoxFor(e => Model.ExpenseClaimItems[i].Amount, new { @class = "numericTb", @id = "totalPrice" + i, @onblur = "javascript:changeECFExRate()" })
                    @Html.ValidationMessageFor(e => Model.ExpenseClaimItems[i].Amount)
                </td>
                <td style="text-align: right;">
                    @Html.TextBoxFor(e => Model.ExpenseClaimItems[i].EntityExpseItem.ConvertedAmount, new { @class = "numericTb", @id = "convPrice" + i, @readonly = "readonly" })
                </td>
            </tr>
           }
        }
        <tr>
            <td colspan="2" class="gridheader" align="right">
                Currency of ECF
            </td>
            <td align="center">
                @Model.ExpsCurrency.ShortName
            </td>
            <td class="gridheader" align="right">
                Total
            </td>
            <td align="right">
                @Html.TextBoxFor(e => e.EntityExpseRqst.TotalValue, new { @id = "totalVal", @class = "numericTb", @readonly = "readonly" })
            </td>
            <td align="right">
                <input type="text" class="numericTb" id="totalAmount" name="totalConvVal" readonly="readonly" />
            </td>
        </tr>
        <tr>
            <td colspan="2" class="gridheader3" align="right">
                Master Budget Currency
            </td>
            <td align="center">
                @Html.DropDownListFor(e => e.MBCurrencyId, Model.Currencies, new { @class = "smallControl", @id = "mbCurrencyId", @onchange = "calculateMBValue()" })
            </td>
            <td class="gridheader3" align="right">
                Master Budget Value
            </td>
            <td align="right">
                @Html.TextBoxFor(e => e.MBValue, new { @id = "mbValue", @class = "numericTb" })
            </td>
            <td class="gridheader3">
                ECF Value
                <input type="hidden" id="origLocalValue" />
                <input type="hidden" id="origFxValue" />
                <input type="hidden" id="ecfItemCount" value="@Model.ExpenseClaimItems.Count" />
            </td>
        </tr>
    </table>
    <br />
    <table width="98%" align="center">
        <tr>
            <td width="50%" align="right">
                <input type="submit" value="Approve" class="btn tertiary" />
            </td>
            <td width="50%">
                <input type="button" class="btn tertiary" value=" Reject " onclick="sendRequest('/RequestReview/LoadRejectECF/@Model.EntityExpseRqst.Id', 'popup-page', 'popup-loading'); CenterPopup();" />
            </td>
        </tr>   
    </table>
}
